#ifndef __SDCARD_H__
#define __SDCARD_H__


#include "driver/spi_master.h"


#define MOUNT_POINT     "/sdcard"
#define FILE_NUM_MAX        100 //允许记录文件名的最大数量
#define FILE_NAME_LEN_MAX   50 //文件名最大长度
#define FILE_PATH_LEN_MAX   100
#define FILE_NUM_IN_PAGE    9 //一个Page中文件名数量
//
#define FILE_MODE_READ           "r" //读取
#define FILE_MODE_WRITE          "w" //写入
#define FILE_MODE_READ_WRITE     "r+" //读写
//
#define FILE_WRITE_BLOCK_SIZE        1024
//
#define DEFAULT_BK_FILE_PATH        "/EPD/bk/bk.txt" //默认界面文件
#define DEFAULT_IMG_DIR             "/EPD/img/" //默认图像路径

esp_err_t SDCard_Init(spi_host_device_t host_id);
void SDCard_Deinit();
//
esp_err_t SDCard_File_Open(char *file_path, const char *mode);
esp_err_t SDCard_File_Read(char *buf, uint16_t size);
esp_err_t SDCard_File_Read_Img(char *imgVal, uint16_t len);
esp_err_t SDCard_File_Write_Img(char *imgVal, uint16_t len);
void SDCard_File_Close();
//
int8_t SDCard_File_Copy_Img();
int8_t SDCard_File_Delete_Img();
//
int8_t SDCard_File_ListAllNames(char *dir);
// int8_t SDCard_File_GetNames(uint8_t page, char names[FILE_NUM_IN_PAGE][FILE_NAME_LEN_MAX]);
int8_t SDCard_File_GetNames(char out_names[FILE_NUM_IN_PAGE][FILE_NAME_LEN_MAX]);
void SDCard_File_GetOnePath(char out_name[FILE_PATH_LEN_MAX]);
// void SDCard_File_CurrentPage_Set(int8_t page);
int8_t SDCard_File_CurrentPage_Get();
int8_t SDCard_File_CurrentIdx_Set(int8_t idx);
int8_t SDCard_File_CurrentIdx_Get();
int8_t SDCard_File_GetSelectPosition();
int8_t SDCard_File_IsCurrentIdxAtTail();

//
void SDCard_Test();
void SDCard_Test_2();


#endif
